﻿using System.Collections.Generic;

namespace IterationLife.Extensions.Dtos
{
    /// <summary>
    /// 分页数据
    /// </summary>
    public class PagedData<TPageData>
    {
        /// <summary>
        /// 初始化分页数据
        /// </summary>
        /// <param name="pageDatas">分页数据</param>
        /// <param name="page">页数</param>
        /// <param name="size">条数</param>
        /// <param name="totalCount">总数</param>
        public PagedData(IEnumerable<TPageData> pageDatas, int page, int size, int totalCount)
        {
            PageDatas = pageDatas;
            TotalCount = totalCount;
            Page = page;
            Size = size;
            if (TotalCount % Size == 0)
                PageCount = TotalCount / Size;
            else
                PageCount = TotalCount / Size + 1;
        }

        /// <summary>
        /// 分页数据
        /// </summary>
        public IEnumerable<TPageData> PageDatas { get; set; }
        /// <summary>
        /// 页数
        /// </summary>
        public int Page { get; set; }
        /// <summary>
        /// 条数
        /// </summary>
        public int Size { get; set; }
        /// <summary>
        /// 总数
        /// </summary>
        public int TotalCount { get; set; }
        /// <summary>
        /// 总页数
        /// </summary>
        public int PageCount { get; private set; }
    }

}
